<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function slidStr(str) {
            let strArr = [...str];
            let result = []
            function findRepeat(start, end) {

                for (var i = start; i < str.length; i++) {
                   
                    if (str[i] === str[start] && start !== end) {
                        end = i
                    } else {
                        end++
                        if (end < str.length - 1) {
                            findRepeat(start, end)
                        }
                    }
                }
                if (end > start) {
                    let newArr = [... new Set(strArr.slice(start, end + 1))]
                    for (var i = 0; i < newArr.length; i++) {
                        if (str.lastIndexOf(newArr[i]) > end) {
                            end = str.lastIndexOf(newArr[i])
                        }
                    }
                    result.push(end - start + 1)
                    console.log(end)

                    start = end + 1;
                    end = end + 1;
                    findRepeat(start, end)

                }
                findRepeat(0, 0)
            }

            return result
        }
        console.log(slidStr('abcads'))
    </script>
</body>

</html>